Skip to content

Dog Age Calculator#90

Open
AdyaTech wants to merge 1 commit into
Grow-with-Open-Source:mainfrom
AdyaTech:DogAgeCalculator
Open

Dog Age Calculator#90
AdyaTech wants to merge 1 commit into
Grow-with-Open-Source:mainfrom
AdyaTech:DogAgeCalculator

Conversation

@AdyaTech
Copy link
Copy Markdown

@AdyaTech AdyaTech commented May 7, 2026

🐶 Dog Age Calculator (Using Python)

📌 Introduction

The Dog Age Calculator is a simple Python program that converts a dog’s age from human years into dog years using a commonly used calculation method.

The program takes user input, validates the age, and applies different formulas depending on whether the dog is younger or older than two years.


🚀 Features

  • Converts human years into dog years
  • Handles different age calculation formulas
  • Validates negative age input
  • Simple command-line interaction
  • Beginner-friendly Python project

💻 Example

Input a dog's age in human years: 5
The dog's age in dog's years is 33

@github-actions github-actions Bot requested a review from iamwatchdogs May 7, 2026 11:02
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

👋 @AdyaTech
Thank you for raising your pull request.
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.

@iamwatchdogs iamwatchdogs changed the title Contributing my Python project by the name of Dog Age Calculator in t… Dog Age Calculator May 20, 2026
Copy link
Copy Markdown
Contributor

@iamwatchdogs iamwatchdogs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AdyaTech, please make the following changes to proceed with your PR:

  • Update the Python script with relevant changes.
  • Rename your project directory based on the specified guidelines.

Please don't create a new commit to implement the requested changes. Instead, amend the existing commit and force push the changes to the PR branch.

Comment on lines +1 to +16
# Request input from the user to provide a dog's age in human years and convert it to an integer
h_age = int(input("Input a dog's age in human years: "))

# Check if the entered age is less than zero; if true, display an error message and exit the program
if h_age < 0:
print("Age must be a positive number.")
exit()
# If the entered age is 2 years or less, calculate the dog's age in dog's years using the formula 10.5 times the human years
elif h_age <= 2:
d_age = h_age * 10.5
# For ages greater than 2, calculate the dog's age in dog's years using the formula 21 plus 4 times the remaining human years after 2
else:
d_age = 21 + (h_age - 2) * 4

# Display the calculated dog's age in dog's years
print("The dog's age in dog's years is", d_age) No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Don't add too many comments; code should be self-documenting
  • Check for valid input
  • If the script fails due to unexpected behaviours, then it should exit with a non-zero code.
  • The ternary operator is just a preference
Suggested change
# Request input from the user to provide a dog's age in human years and convert it to an integer
h_age = int(input("Input a dog's age in human years: "))
# Check if the entered age is less than zero; if true, display an error message and exit the program
if h_age < 0:
print("Age must be a positive number.")
exit()
# If the entered age is 2 years or less, calculate the dog's age in dog's years using the formula 10.5 times the human years
elif h_age <= 2:
d_age = h_age * 10.5
# For ages greater than 2, calculate the dog's age in dog's years using the formula 21 plus 4 times the remaining human years after 2
else:
d_age = 21 + (h_age - 2) * 4
# Display the calculated dog's age in dog's years
print("The dog's age in dog's years is", d_age)
try:
human_years = float(input("Input a dog's age in human years: "))
except ValueError:
print("Please enter a valid number")
exit(1)
if human_years < 0:
print("Age must be a positive number.")
exit(1)
dog_age = human_years * 10.5 if human_years <= 2 else 21 + (human_years - 2) * 4
print("The dog's age in dog's years is", dog_age)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants